package com.example.book_subscribe.mine.mapper;

import com.example.book_subscribe.bookList.result.BookCommentsResult;
import com.example.book_subscribe.bookList.result.BookResult;
import com.example.book_subscribe.mine.dto.NoteDetailDto;
import com.example.book_subscribe.mine.result.MineResult;
import com.example.book_subscribe.mine.result.MyCommentResult;
import com.example.book_subscribe.mine.result.MySubscribeResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface MineMapper {
    @Select("select user_url,user_wxname from user  where open_id=#{openid}")
    MineResult searchMine(@Param("openid") String openid);

    @Select("SELECT s.book_id, s.state,b.book_name, b.book_url,b.book_author " +
            "FROM subscribe s " +
            "JOIN book_list b ON s.book_id = b.book_id " +
            "WHERE s.open_id = #{openid} and s.state=1")
    ArrayList<MySubscribeResult> getMySubscribe(@Param("openid") String openid);
    @Select("SELECT c.comments_content, c.user_comments,c.book_id, b.book_name,b.book_url,b.book_author " +
            "FROM comment_list c " +
            "JOIN book_list b ON c.book_id = b.book_id " +
            "WHERE c.open_id = #{openid}")
    ArrayList<MyCommentResult> getMyComment(@Param("openid") String openid);

    @Select("select bl.book_name,bl.book_id from book_note bn join book_list bl on bn.book_id=bl.book_id where bn.open_id=#{openid}")
    ArrayList<BookResult> getNoteList(@Param("openid") String openid);
    @Select("select note_text from book_note  where open_id=#{NoteDetail.openId} and book_id=#{NoteDetail.bookId}")
    String getNoteDetail(@Param("NoteDetail") NoteDetailDto NoteDetail);
}
